<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%--@ taglib prefix="spring" uri="http://www.springframework.org/tags"--%>
<%--@ taglib prefix="form" uri="http://www.springframework.org/tags/form"--%>
<%--@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"--%>
<%--@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"--%>

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<s:head />
<title>课程列表</title>
</head>
<body>
<div style="text-align:right">欢迎您，${currentUser.name} | <a href="logout">退出</a> </div>
<h2>可选课程</h2>
<table>
	<tr>
		<td>编号</td>
		<td>课程名</td>
		<td>授课老师</td>
		<td>学分</td>
		<td>操作</td>
	</tr>
	<s:if test="availableCourseList.size > 0">
	<%-- <c:forEach items="${availableCourseList}" var="course"> --%>
	<s:iterator value="availableCourseList">
		<tr>
			<td><s:property value="id" /></td>
			<td><s:property value="name" /></td>
			<td>
				<%-- <c:forEach items="${course.teachers }" var="teacher"> --%>
				<s:iterator value="teachers">
					<%-- ${teacher.name } --%>
					<s:property value="name" />&nbsp;
				</s:iterator>
				<%-- </c:forEach> --%>
			</td>
			<td><s:property value="score" /></td>
			<td>
				<%-- <a href="select?courseId=${course.id}">选择</a> --%>
				<s:url action="select" id="selectUrl">
					<s:param name="courseId" value="id" />
				</s:url>
				<s:a href="%{selectUrl}">选择</s:a>
			</td>
		</tr>
		</s:iterator>
		</s:if>
	<%-- </c:forEach> --%>
</table>

<hr/>

<h2>已选择课程</h2>
<table>
	<tr>
		<td>编号</td>
		<td>课程名</td>
		<td>授课老师</td>
		<td>学分</td>
		<td>操作</td>
	</tr>
	<%-- <c:forEach items="${selectedCourseList}" var="course"> --%>
	<s:if test="selectedCourseList.size > 0">
	<s:iterator value="selectedCourseList">
		<tr>
			<td><s:property value="id" /></td>
			<td><s:property value="name" /></td>
			<td>
				<%-- <c:forEach items="${course.teachers }" var="teacher"> --%>
				<s:iterator value="teachers">
					<s:property value="name" />&nbsp;
				</s:iterator>
					
				<%-- </c:forEach> --%>
			</td>
			<td> <s:property value="score" /></td>
			<td>
				<%-- <a href="unselect?courseId=${course.id}">取消选择</a>  --%>
				<s:url id="unselectUrl" action="unselect">
					<s:param name="courseId" value="id"/>
				</s:url>
				<s:a href="%{unselectUrl}">取消选择</s:a>
			</td>
		</tr>
		</s:iterator>
		</s:if>
	<%-- </c:forEach> --%>
</table>

</body>
</html>